package com.shxy.entity.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.shxy.util.converter.AbstractEnumConverter;
import com.shxy.util.converter.IEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.lang.Nullable;

/**
 * 民族枚举
 */
@Getter
@AllArgsConstructor
public enum DegreeEnum implements IEnum<String> {
    BOSHI("01", "博士"),
    SHUOSHI("02","硕士"),
    XUESHI("03","学士"),
    DEXWXS("04","第二学位学士"),
    QITA("05","其他")

    ;
    private String code;
    private String name;

    /**
     * 类型转换器
     */
    public static class Converter extends AbstractEnumConverter<DegreeEnum, String> {
        public Converter() {
            super(DegreeEnum.class);
        }
    }


    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    @Nullable
    public static DegreeEnum resolve(String name) {
        for(DegreeEnum degreeEnum: DegreeEnum.values()) {
            if(name.equals(degreeEnum.getName())){
                return degreeEnum;
            }
        }
        return null;
    }
}
